@extends('admin.layout.app')

@section('title', '簡訊模板')
@section('menu', broute('message.template.index'))

@section('style')
<style>
    .tags span {
        padding: 2px 4px;
        color: #d14;
        white-space: nowrap;
        background-color: #f7f7f9;
        border: 1px solid #e1e1e8;
        border-radius: 5px;
        cursor: pointer;
    }
</style>
@endsection

@section('content')
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">新增简讯模板分类</div>
                <div class="layui-card-body">
                    <form class="layui-form" method="post" action="/message/template/edit">
                        <div class="layui-form-item">
                            <label class="layui-form-label">模板类别</label>
                            <div class="layui-input-block">
                                <select name="type" lay-filter="aihao">
                                    <option value="0">请选择</option>
                                    @foreach ($customMap ?? [] as $key => $val)
                                    <option value="{{$key}}" @if(isset($row['type']) && $row['type'] == $key) selected @endif>{{$val}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">模板標題</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" autocomplete="off" placeholder="请输入模板名称" required class="layui-input" value="{{ $row['title']??'' }}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">模板内容</label>
                            <div class="layui-input-block">
                                <textarea style="height: 260px;" name="content" id="content" placeholder="请输入模板内容" required lay-verify="required" class="layui-textarea">{{ $row['content']??'' }}</textarea>
                            </div>
                        </div>
                        @empty($row['id'])
                        @else
                            <input type="hidden" name="id" value="{{$row['id']}}">
                        @endempty
                        <div class="layui-form-item">
                            <button style="margin-left: 110px;" class="layui-btn" lay-submit="" lay-filter="demo2">提交</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@endsection

@section('script')
<script>
$(function () {
    $(".map-tags").click(function () {
        var tag = $(this).html().trim();
        var content  = $("#content").val();
        var content_with_tag = content+tag;
        $("#content").val(content_with_tag);
    });
});
</script>
@endsection
